package com.androidy;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class main extends Activity implements OnClickListener{
    ImageView btn_blue, btn_red, btn_yellow, btn_green;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        LinearLayout container = (LinearLayout)this.findViewById(R.id.container);
        container.setBackgroundResource(R.drawable.back);
        
        btn_blue = (ImageView)this.findViewById(R.id.btn_blue);
        btn_red = (ImageView)this.findViewById(R.id.btn_red);
        btn_green = (ImageView)this.findViewById(R.id.btn_green);
        btn_yellow = (ImageView)this.findViewById(R.id.btn_yellow);

	    custAnimationListener cAL1 = new custAnimationListener("transform", 500, 0, 480, 0, 0, 0);
	    cAL1.startAnimation(btn_green, true);
	    custAnimationListener cAL2 = new custAnimationListener("transform", 500, 100, 480, 0, 0, 0);
	    cAL2.startAnimation(btn_blue, true);
	    custAnimationListener cAL3 = new custAnimationListener("transform", 500, 200, 480, 0, 0, 0);
	    cAL3.startAnimation(btn_red, true);
	    custAnimationListener cAL4 = new custAnimationListener("transform", 500, 300, 480, 0, 0, 0);
	    cAL4.startAnimation(btn_yellow, true);

	    btn_blue.setOnClickListener(this);
	    btn_red.setOnClickListener(this);
	    btn_yellow.setOnClickListener(this);
	    btn_green.setOnClickListener(this);
    }

	@Override
	public void onClick(View v) {
		Intent i = null;
		if (v == btn_blue)
			i = new Intent(this, GalleryActivity.class);	
		else if (v == btn_red)
			i = new Intent(this, youtube_list.class);
		else if (v == btn_green)
			i = new Intent(this, aboutme.class);
		else if (v == btn_yellow)
			i = new Intent(this, contact.class);
			
		// TODO Auto-generated method stub
	    custAnimationListener cAL1 = new custAnimationListener("transform", 500, 0, 0, 0, -480, 0);
	    cAL1.startAnimation(btn_green, false);
	    custAnimationListener cAL2 = new custAnimationListener("transform", 500, 100, 0, 0, -480, 0);
	    cAL2.startAnimation(btn_blue, false);
	    custAnimationListener cAL3 = new custAnimationListener("transform", 500, 200, 0, 0, -480, 0);
	    cAL3.startAnimation(btn_red, false);
	    custAnimationListener cAL4 = new custAnimationListener("transform", 500, 300, 0, 0, -480, 0);
	    cAL4.startAnimation(btn_yellow, false, i, this);
	    
	}
	
	public void onResume(){
		super.onResume();
		if (btn_green.getVisibility()== View.INVISIBLE){
		    custAnimationListener cAL4 = new custAnimationListener("transform", 500, 0, -480, 0, 0, 0);
		    cAL4.startAnimation(btn_green, true);			
		}
		if (btn_blue.getVisibility()== View.INVISIBLE){
		    custAnimationListener cAL1 = new custAnimationListener("transform", 500, 100, -480, 0, 0, 0);
		    cAL1.startAnimation(btn_blue, true);			
		}
		if (btn_red.getVisibility()== View.INVISIBLE){
		    custAnimationListener cAL2 = new custAnimationListener("transform", 500, 200, -480, 0, 0, 0);
		    cAL2.startAnimation(btn_red, true);			
		}
		if (btn_yellow.getVisibility()== View.INVISIBLE){
		    custAnimationListener cAL3 = new custAnimationListener("transform", 500, 300, -480, 0, 0, 0);
		    cAL3.startAnimation(btn_yellow, true);			
		}
	}

}
